package gui.mpm;

import javax.swing.JPanel;

import net.miginfocom.swing.MigLayout;

import javax.swing.border.TitledBorder;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JList;
import javax.swing.AbstractListModel;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Iterator;

import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.JCheckBox;
import javax.swing.JSeparator;
import javax.swing.JScrollPane;

import org.dom4j.InvalidXPathException;

import utilities.Services;

import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;

import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;

import java.awt.SystemColor;
import java.awt.Font;

/**
 * @author Idan
 * MPM Schedule planning GUI
 */
public class MPMPlaning extends JPanel
{
	private JTextField engraveTargetTextField;
	private JTextField polishTargetTextFieldtextField;
	private JTextField qcTargetTextField;
	private JTextField packagingTargetTextField;
	
	private JLabel[] dayLabels;
	private JCheckBox[] workdayChoice;
	private JTextField[] engraveQuantities;
	private JTextField[] polishQuantities;
	private JTextField[] qcQuantities;
	private JTextField[] packagingQuantities;
	private JComboBox yearComboBox;
	private JComboBox monthComboBox;
	private JButton loadSchedule;
	private JLabel label_29;
	private JLabel label_30;
	private JLabel label_31;
	private MPMFrame myframe;
	
	private int[] workdaysFlagArray1 = new int[31];
	private int[] workdaysFlagArray2 = new int[31];
	private int[] workdaysFlagArray3 = new int[31];
	private int[] workdaysFlagArray4 = new int[31];
	private JButton createPlan;
	private JButton exitButton;
	
	private static ImageIcon icon = new ImageIcon("/Hanit/src/graphics/bg.jpg");
	private static Image image = icon.getImage();
	
	
	public MPMPlaning(MPMFrame mpmFrame)
	{
		setBackground(new Color(173, 216, 230));
		
		setLayout(new MigLayout("", "[][grow][]", "[][][grow][][]"));
		this.myframe = mpmFrame;
	
		
		JPanel panel = new JPanel(){
			@Override
			public void paintComponent(Graphics g) {
	        Graphics2D g2d = (Graphics2D) g;
	        Color color1 = getBackground();
	        Color color2 = color1.darker();
	        int w = getWidth();
	        int h = getHeight(); 
	        GradientPaint gp = new GradientPaint(
	                0, 0, color1,
	                0, h, color2);

	        g2d.setPaint(gp);
	        g2d.fillRect(0, 0, w, h);
	        }
		    
		};
		panel.setBackground(new Color(173, 216, 230));
		panel.setBorder(new TitledBorder(null, "\u05EA\u05DB\u05E0\u05D5\u05DF", TitledBorder.RIGHT, TitledBorder.TOP, null, null));
		add(panel, "cell 1 2,grow");
		panel.setLayout(new MigLayout("", "[grow][grow,center][grow]", "[][grow][]"));
		
		loadSchedule = new JButton("בחירה");
		loadSchedule.setFont(new Font("Tahoma", Font.PLAIN, 13));
		loadSchedule.addMouseListener(new MouseAdapter() 
		{
			@Override
			public void mouseClicked(MouseEvent arg0)
			{
			
				// get year
				int year = Integer.parseInt(yearComboBox.getSelectedItem().toString());
				int month = monthComboBox.getSelectedIndex(); // 0 = January, 11 = December
	
				initializeFields(year, month, false);

			}
		});
		panel.add(loadSchedule, "flowx,cell 1 0,alignx center,aligny center");
		
		yearComboBox = new JComboBox();
		yearComboBox.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(yearComboBox, "cell 1 0,alignx center,aligny center");
		yearComboBox.setPreferredSize(new Dimension(70, 30));
		
		JLabel label = new JLabel("שנה:");
		label.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(label, "cell 1 0,alignx center,aligny center");
		
		monthComboBox = new JComboBox();
		monthComboBox.setFont(new Font("Tahoma", Font.PLAIN, 13));
		monthComboBox.setModel(new DefaultComboBoxModel(new String[] {"ינואר", "פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"}));
		panel.add(monthComboBox, "cell 1 0,alignx center,aligny center");
		
		JLabel monthLabel = new JLabel("חודש:");
		monthLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel.add(monthLabel, "cell 1 0,aligny center");
		
		JScrollPane scrollPane = new JScrollPane();
		panel.add(scrollPane, "cell 1 1,grow");
		
		JPanel panel_1 = new JPanel(){@Override
			public void paintComponent(Graphics g) {
	        Graphics2D g2d = (Graphics2D) g;
	        Color color1 = getBackground();
	        Color color2 = color1.darker();
	        int w = getWidth();
	        int h = getHeight(); 
	        GradientPaint gp = new GradientPaint(
	                0, 0, color1,
	                0, h, color2);

	        g2d.setPaint(gp);
	        g2d.fillRect(0, 0, w, h);
	        }};
		panel_1.setBackground(new Color(173, 216, 230));
		scrollPane.setViewportView(panel_1);
		panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_1.setLayout(new MigLayout("", "[grow][][][][30px][][][][][][][][][grow]", "[][][baseline][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]"));
		
		
		
		//Create arrays of gui elements to dynamically set.
		
		JLabel day1;
		JLabel day2;
		JLabel day3;
		JLabel day4;
		JLabel day5;
		JLabel day6;
		JLabel day7;
		JLabel day8;
		JLabel day9;
		JLabel day10;
		JLabel day11;
		JLabel day12;
		JLabel day13;
		JLabel day14;
		JLabel day15;
		JLabel day16;
		JLabel day17;
		JLabel day18;
		JLabel day19;
		JLabel day20;
		JLabel day21;
		JLabel day22;
		JLabel day23;
		JLabel day24;
		JLabel day25;
		JLabel day26;
		JLabel day27;
		JLabel day28;
		JLabel day29;
		JLabel day30;
		JLabel day31;
		
		JCheckBox checkBox_1;
		JCheckBox checkBox_2;
		JCheckBox checkBox_3;
		JCheckBox checkBox_4;
		JCheckBox checkBox_5;
		JCheckBox checkBox_6;
		JCheckBox checkBox_7;
		JCheckBox checkBox_8;
		JCheckBox checkBox_9;
		JCheckBox checkBox_10;
		JCheckBox checkBox_11;
		JCheckBox checkBox_12;
		JCheckBox checkBox_13;
		JCheckBox checkBox_14;
		JCheckBox checkBox_15;
		JCheckBox checkBox_16;
		JCheckBox checkBox_17;
		JCheckBox checkBox_18;
		JCheckBox checkBox_19;
		JCheckBox checkBox_20;
		JCheckBox checkBox_21;
		JCheckBox checkBox_22;
		JCheckBox checkBox_23;
		JCheckBox checkBox_24;
		JCheckBox checkBox_25;
		JCheckBox checkBox_26;
		JCheckBox checkBox_27;
		JCheckBox checkBox_28;
		JCheckBox checkBox_29;
		JCheckBox checkBox_30;
		JCheckBox checkBox_31;
		
		JTextField engrave1QuantityTextField;
		JTextField engrave2QuantityTextField;
		JTextField engrave3QuantityTextField;
		JTextField engrave4QuantityTextField;
		JTextField engrave5QuantityTextField;
		JTextField engrave6QuantityTextField;
		JTextField engrave7QuantityTextField;
		JTextField engrave8QuantityTextField;
		JTextField engrave9QuantityTextField;
		JTextField engrave10QuantityTextField;
		JTextField engrave11QuantityTextField;
		JTextField engrave12QuantityTextField;
		JTextField engrave13QuantityTextField;
		JTextField engrave14QuantityTextField;
		JTextField engrave15QuantityTextField;
		JTextField engrave16QuantityTextField;
		JTextField engrave17QuantityTextField;
		JTextField engrave18QuantityTextField;
		JTextField engrave19QuantityTextField;
		JTextField engrave20QuantityTextField;
		JTextField engrave21QuantityTextField;
		JTextField engrave22QuantityTextField;
		JTextField engrave23QuantityTextField;
		JTextField engrave24QuantityTextField;
		JTextField engrave25QuantityTextField;
		JTextField engrave26QuantityTextField;
		JTextField engrave27QuantityTextField;
		JTextField engrave28QuantityTextField;
		JTextField engrave29QuantityTextField;
		JTextField engrave30QuantityTextField;
		JTextField engrave31QuantityTextField;
		
		JTextField polish1QuantityTextField;
		JTextField polish2QuantityTextField;
		JTextField polish3QuantityTextField;
		JTextField polish4QuantityTextField;
		JTextField polish5QuantityTextField;
		JTextField polish6QuantityTextField;
		JTextField polish7QuantityTextField;
		JTextField polish8QuantityTextField;
		JTextField polish9QuantityTextField;
		JTextField polish10QuantityTextField;
		JTextField polish11QuantityTextField;
		JTextField polish12QuantityTextField;
		JTextField polish13QuantityTextField;
		JTextField polish14QuantityTextField;
		JTextField polish15QuantityTextField;
		JTextField polish16QuantityTextField;
		JTextField polish17QuantityTextField;
		JTextField polish18QuantityTextField;
		JTextField polish19QuantityTextField;
		JTextField polish20QuantityTextField;
		JTextField polish21QuantityTextField;
		JTextField polish22QuantityTextField;
		JTextField polish23QuantityTextField;
		JTextField polish24QuantityTextField;
		JTextField polish25QuantityTextField;
		JTextField polish26QuantityTextField;
		JTextField polish27QuantityTextField;
		JTextField polish28QuantityTextField;
		JTextField polish29QuantityTextField;
		JTextField polish30QuantityTextField;
		JTextField polish31QuantityTextField;
		
		JTextField qc1QuantityTextField;
		JTextField qc2QuantityTextField;
		JTextField qc3QuantityTextField;
		JTextField qc4QuantityTextField;
		JTextField qc5QuantityTextField;
		JTextField qc6QuantityTextField;
		JTextField qc7QuantityTextField;
		JTextField qc8QuantityTextField;
		JTextField qc9QuantityTextField;
		JTextField qc10QuantityTextField;
		JTextField qc11QuantityTextField;
		JTextField qc12QuantityTextField;
		JTextField qc13QuantityTextField;
		JTextField qc14QuantityTextField;
		JTextField qc15QuantityTextField;
		JTextField qc16QuantityTextField;
		JTextField qc17QuantityTextField;
		JTextField qc18QuantityTextField;
		JTextField qc19QuantityTextField;
		JTextField qc20QuantityTextField;
		JTextField qc21QuantityTextField;
		JTextField qc22QuantityTextField;
		JTextField qc23QuantityTextField;
		JTextField qc24QuantityTextField;
		JTextField qc25QuantityTextField;
		JTextField qc26QuantityTextField;
		JTextField qc27QuantityTextField;
		JTextField qc28QuantityTextField;
		JTextField qc29QuantityTextField;
		JTextField qc30QuantityTextField;
		JTextField qc31QuantityTextField;
		
		JTextField packaging1QuantityTextField;
		JTextField packaging2QuantityTextField;
		JTextField packaging3QuantityTextField;
		JTextField packaging4QuantityTextField;
		JTextField packaging5QuantityTextField;
		JTextField packaging6QuantityTextField;
		JTextField packaging7QuantityTextField;
		JTextField packaging8QuantityTextField;
		JTextField packaging9QuantityTextField;
		JTextField packaging10QuantityTextField;
		JTextField packaging11QuantityTextField;
		JTextField packaging12QuantityTextField;
		JTextField packaging13QuantityTextField;
		JTextField packaging14QuantityTextField;
		JTextField packaging15QuantityTextField;
		JTextField packaging16QuantityTextField;
		JTextField packaging17QuantityTextField;
		JTextField packaging18QuantityTextField;
		JTextField packaging19QuantityTextField;
		JTextField packaging20QuantityTextField;
		JTextField packaging21QuantityTextField;
		JTextField packaging22QuantityTextField;
		JTextField packaging23QuantityTextField;
		JTextField packaging24QuantityTextField;
		JTextField packaging25QuantityTextField;
		JTextField packaging26QuantityTextField;
		JTextField packaging27QuantityTextField;
		JTextField packaging28QuantityTextField;
		JTextField packaging29QuantityTextField;
		JTextField packaging30QuantityTextField;
		JTextField packaging31QuantityTextField;
		
		
		
		JLabel[] days = {day1 = new JLabel(), day2 = new JLabel(), day3 = new JLabel(), day4 = new JLabel(), day5 = new JLabel(), day6 = new JLabel(), day7 = new JLabel(), day8 = new JLabel(), day9 = new JLabel(), day10 = new JLabel(), day11 = new JLabel(), day12 = new JLabel(), day13 = new JLabel(), day14 = new JLabel(), day15 = new JLabel(), day16 = new JLabel(), day17 = new JLabel(), day18 = new JLabel(), day19 = new JLabel(), day20 = new JLabel(), day21 = new JLabel(), day22 = new JLabel(), day23 = new JLabel(), day24 = new JLabel(), day25 = new JLabel(), day26 = new JLabel(), day27 = new JLabel(), day28 = new JLabel(), day29 = new JLabel(), day30 = new JLabel(), day31 = new JLabel()};
		JCheckBox[] choice = {checkBox_1 = new JCheckBox("",true), checkBox_2 = new JCheckBox("",true), checkBox_3 = new JCheckBox("",true), checkBox_4 = new JCheckBox("",true), checkBox_5 = new JCheckBox("",true), checkBox_6 = new JCheckBox("",true), checkBox_7 = new JCheckBox("",true), checkBox_8 = new JCheckBox("",true), checkBox_9 = new JCheckBox("",true), checkBox_10 = new JCheckBox("",true), checkBox_11 = new JCheckBox("",true), checkBox_12 = new JCheckBox("",true), checkBox_13 = new JCheckBox("",true), checkBox_14 = new JCheckBox("",true), checkBox_15 = new JCheckBox("",true), checkBox_16 = new JCheckBox("",true), checkBox_17 = new JCheckBox("",true), checkBox_18 = new JCheckBox("",true), checkBox_19 = new JCheckBox("",true), checkBox_20 = new JCheckBox("",true), checkBox_21 = new JCheckBox("",true), checkBox_22 = new JCheckBox("",true), checkBox_23 = new JCheckBox("",true), checkBox_24 = new JCheckBox("",true), checkBox_25 = new JCheckBox("",true), checkBox_26 = new JCheckBox("",true), checkBox_27 = new JCheckBox("",true), checkBox_28 = new JCheckBox("",true), checkBox_29 = new JCheckBox("",true), checkBox_30 = new JCheckBox("",true), checkBox_31 = new JCheckBox("",true), };
		JTextField[] engraveQuantity = {engrave1QuantityTextField = new JTextField(), engrave2QuantityTextField = new JTextField(), engrave3QuantityTextField = new JTextField(), engrave4QuantityTextField = new JTextField(), engrave5QuantityTextField = new JTextField(), engrave6QuantityTextField = new JTextField(), engrave7QuantityTextField = new JTextField(), engrave8QuantityTextField = new JTextField(), engrave9QuantityTextField = new JTextField(), engrave10QuantityTextField = new JTextField(), engrave11QuantityTextField = new JTextField(), engrave12QuantityTextField = new JTextField(), engrave13QuantityTextField = new JTextField(), engrave14QuantityTextField = new JTextField(), engrave15QuantityTextField = new JTextField(), engrave16QuantityTextField = new JTextField(), engrave17QuantityTextField = new JTextField(), engrave18QuantityTextField = new JTextField(), engrave19QuantityTextField = new JTextField(), engrave20QuantityTextField = new JTextField(), engrave21QuantityTextField = new JTextField(), engrave22QuantityTextField = new JTextField(), engrave23QuantityTextField = new JTextField(), engrave24QuantityTextField = new JTextField(), engrave25QuantityTextField = new JTextField(), engrave26QuantityTextField = new JTextField(), engrave27QuantityTextField = new JTextField(), engrave28QuantityTextField = new JTextField(), engrave29QuantityTextField = new JTextField(), engrave30QuantityTextField = new JTextField(), engrave31QuantityTextField = new JTextField()};
		engrave31QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave30QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave29QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave28QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave27QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave26QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave25QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave24QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave23QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave22QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave21QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave20QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave19QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave18QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave17QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave16QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave15QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave14QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave13QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave12QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave11QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave10QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave9QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave8QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave7QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave6QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave5QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave4QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave3QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave2QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engrave1QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		JTextField[] polishQuantity = {polish1QuantityTextField = new JTextField(), polish2QuantityTextField = new JTextField(), polish3QuantityTextField = new JTextField(), polish4QuantityTextField = new JTextField(), polish5QuantityTextField = new JTextField(), polish6QuantityTextField = new JTextField(), polish7QuantityTextField = new JTextField(), polish8QuantityTextField = new JTextField(), polish9QuantityTextField = new JTextField(), polish10QuantityTextField = new JTextField(), polish11QuantityTextField = new JTextField(), polish12QuantityTextField = new JTextField(), polish13QuantityTextField = new JTextField(), polish14QuantityTextField = new JTextField(), polish15QuantityTextField = new JTextField(), polish16QuantityTextField = new JTextField(), polish17QuantityTextField = new JTextField(), polish18QuantityTextField = new JTextField(), polish19QuantityTextField = new JTextField(), polish20QuantityTextField = new JTextField(), polish21QuantityTextField = new JTextField(), polish22QuantityTextField = new JTextField(), polish23QuantityTextField = new JTextField(), polish24QuantityTextField = new JTextField(), polish25QuantityTextField = new JTextField(), polish26QuantityTextField = new JTextField(), polish27QuantityTextField = new JTextField(), polish28QuantityTextField = new JTextField(), polish29QuantityTextField = new JTextField(), polish30QuantityTextField = new JTextField(), polish31QuantityTextField = new JTextField() };
		polish31QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish30QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish29QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish28QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish27QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish26QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish25QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish24QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish23QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish22QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish21QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish20QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish19QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish18QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish17QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish16QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish15QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish14QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish13QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish12QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish11QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish10QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish9QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish8QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish7QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish6QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish5QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish4QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish3QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish2QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polish1QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		JTextField[] qcQuantity = {qc1QuantityTextField = new JTextField(), qc2QuantityTextField = new JTextField(), qc3QuantityTextField = new JTextField(), qc4QuantityTextField = new JTextField(), qc5QuantityTextField = new JTextField(), qc6QuantityTextField = new JTextField(), qc7QuantityTextField = new JTextField(), qc8QuantityTextField = new JTextField(), qc9QuantityTextField = new JTextField(), qc10QuantityTextField = new JTextField(), qc11QuantityTextField = new JTextField(), qc12QuantityTextField = new JTextField(), qc13QuantityTextField = new JTextField(), qc14QuantityTextField = new JTextField(), qc15QuantityTextField = new JTextField(), qc16QuantityTextField = new JTextField(), qc17QuantityTextField = new JTextField(), qc18QuantityTextField = new JTextField(), qc19QuantityTextField = new JTextField(), qc20QuantityTextField = new JTextField(), qc21QuantityTextField = new JTextField(), qc22QuantityTextField = new JTextField(), qc23QuantityTextField = new JTextField(), qc24QuantityTextField = new JTextField(), qc25QuantityTextField = new JTextField(), qc26QuantityTextField = new JTextField(), qc27QuantityTextField = new JTextField(), qc28QuantityTextField = new JTextField(), qc29QuantityTextField = new JTextField(), qc30QuantityTextField = new JTextField(), qc31QuantityTextField = new JTextField()};
		qc31QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc30QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc29QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc28QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc27QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc26QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc25QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc24QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc23QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc22QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc21QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc20QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc19QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc18QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc17QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc16QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc15QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc14QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc13QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc12QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc11QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc10QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc9QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc8QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc7QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc6QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc5QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc4QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc3QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc2QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qc1QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		JTextField[] packagingQuantity = {packaging1QuantityTextField = new JTextField(), packaging2QuantityTextField = new JTextField(), packaging3QuantityTextField = new JTextField(), packaging4QuantityTextField = new JTextField(), packaging5QuantityTextField = new JTextField(), packaging6QuantityTextField = new JTextField(), packaging7QuantityTextField = new JTextField(), packaging8QuantityTextField = new JTextField(), packaging9QuantityTextField = new JTextField(), packaging10QuantityTextField = new JTextField(), packaging11QuantityTextField = new JTextField(), packaging12QuantityTextField = new JTextField(), packaging13QuantityTextField = new JTextField(), packaging14QuantityTextField = new JTextField(), packaging15QuantityTextField = new JTextField(), packaging16QuantityTextField = new JTextField(), packaging17QuantityTextField = new JTextField(), packaging18QuantityTextField = new JTextField(), packaging19QuantityTextField = new JTextField(), packaging20QuantityTextField = new JTextField(), packaging21QuantityTextField = new JTextField(), packaging22QuantityTextField = new JTextField(), packaging23QuantityTextField = new JTextField(), packaging24QuantityTextField = new JTextField(), packaging25QuantityTextField = new JTextField(), packaging26QuantityTextField = new JTextField(), packaging27QuantityTextField = new JTextField(), packaging28QuantityTextField = new JTextField(), packaging29QuantityTextField = new JTextField(), packaging30QuantityTextField = new JTextField(), packaging31QuantityTextField = new JTextField()};
		packaging31QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging30QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging29QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging28QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging27QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging26QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging25QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging24QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging23QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging22QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging21QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging20QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging19QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging18QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging17QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging16QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging15QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging14QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging13QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging12QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging11QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging10QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging9QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging8QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging7QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging6QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging5QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging4QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging3QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging2QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packaging1QuantityTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		
		this.dayLabels=days;
		this.workdayChoice=choice;
		this.engraveQuantities = engraveQuantity;
		this.polishQuantities = polishQuantity;
		this.qcQuantities = qcQuantity;
		this.packagingQuantities = packagingQuantity;
		
		
		
		// JCheckBox Listeners
		
		
		checkBox_1.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,0);
			}
		});
		
		checkBox_2.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,1);
			}
		});
		
		checkBox_3.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,2);
			}
		});
		
		checkBox_4.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,3);
			}
		});
		
		checkBox_5.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,4);
			}
		});
		
		checkBox_6.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,5);
			}
		});
		
		checkBox_7.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,6);
			}
		});
		
		checkBox_8.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,7);
			}
		});
		
		checkBox_9.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,8);
			}
		});
		
		checkBox_10.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,9);
			}
		});
		
		checkBox_11.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,10);
			}
		});
		
		checkBox_12.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,11);
			}
		});
		
		checkBox_13.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,12);
			}
		});
		
		checkBox_14.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,13);
			}
		});
		
		checkBox_15.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,14);
			}
		});
		
		checkBox_16.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,15);
			}
		});
		
		checkBox_17.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,16);
			}
		});
		
		checkBox_18.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,17);
			}
		});
		
		checkBox_19.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,18);
			}
		});
		
		checkBox_20.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,19);
			}
		});
		
		checkBox_21.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,20);
			}
		});
		
		checkBox_22.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,21);
			}
		});
		
		checkBox_23.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,22);
			}
		});
		
		checkBox_24.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,23);
			}
		});
		
		checkBox_25.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,24);
			}
		});
		
		checkBox_26.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,25);
			}
		});
		
		checkBox_27.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,26);
			}
		});
		
		checkBox_28.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,27);
			}
		});
		
		checkBox_29.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,28);
			}
		});
		
		checkBox_30.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,29);
			}
		});
		
		checkBox_31.addItemListener(new ItemListener()
		{	
			public void itemStateChanged(ItemEvent arg0) 
			{
				checkBoxClicked(arg0,30);
			}
		});
		
			
			
		
		
		
		
		
		
		
		// Add the rest of the gui elements
		
		JLabel workingDayLabel = new JLabel("יום עבודה");
		workingDayLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(workingDayLabel, "cell 1 2,alignx center");
		
		JLabel dateLabel = new JLabel("תאריך  ");
		dateLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(dateLabel, "cell 2 2,alignx center,aligny center");
		
		engraveTargetTextField = new JTextField();
		engraveTargetTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		engraveTargetTextField.setText("0");
		engraveTargetTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(engraveTargetTextField, "flowx,cell 5 1,alignx center,aligny center");
		engraveTargetTextField.setColumns(3);
		
		JLabel engraveDailyLabel = new JLabel("יומי:");
		engraveDailyLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(engraveDailyLabel, "cell 6 1,alignx center,aligny center");
		
		JLabel polishDailyLabel = new JLabel("יומי:");
		polishDailyLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(polishDailyLabel, "cell 8 1");
		
		qcTargetTextField = new JTextField();
		qcTargetTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		qcTargetTextField.setText("0");
		qcTargetTextField.setHorizontalAlignment(SwingConstants.CENTER);
		qcTargetTextField.setColumns(3);
		panel_1.add(qcTargetTextField, "flowx,cell 9 1,alignx center,aligny center");
		
		JLabel qcDailyLabel = new JLabel("יומי:");
		qcDailyLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(qcDailyLabel, "cell 10 1");
		
		packagingTargetTextField = new JTextField();
		packagingTargetTextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		packagingTargetTextField.setText("0");
		packagingTargetTextField.setHorizontalAlignment(SwingConstants.CENTER);
		packagingTargetTextField.setColumns(3);
		panel_1.add(packagingTargetTextField, "flowx,cell 11 1,alignx center,aligny center");
		
		polishTargetTextFieldtextField = new JTextField();
		polishTargetTextFieldtextField.setFont(new Font("Tahoma", Font.PLAIN, 13));
		polishTargetTextFieldtextField.setText("0");
		polishTargetTextFieldtextField.setHorizontalAlignment(SwingConstants.CENTER);
		polishTargetTextFieldtextField.setColumns(3);
		panel_1.add(polishTargetTextFieldtextField, "flowx,cell 7 1,alignx center,aligny center");
		
		JLabel packagingDailyLabel = new JLabel("יומי:");
		packagingDailyLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(packagingDailyLabel, "cell 12 1");
		
		JButton engraveButton = new JButton("");
		engraveButton.setIcon(new ImageIcon(MPMPlaning.class.getResource("/graphics/arrowDownSmall.png")));
		engraveButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) 
			{
				for (JTextField iterator : engraveQuantities)
					if (iterator.isEnabled())
						iterator.setText(engraveTargetTextField.getText());
				
			}
		});
		panel_1.add(engraveButton, "cell 5 2,alignx center,aligny center");
		
		JButton polishButton = new JButton("");
		polishButton.setIcon(new ImageIcon(MPMPlaning.class.getResource("/graphics/arrowDownSmall.png")));
		polishButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e)
			{
				for (JTextField iterator : polishQuantities)
					if (iterator.isEnabled())
						iterator.setText(polishTargetTextFieldtextField.getText());
			}
		});
		panel_1.add(polishButton, "cell 7 2,alignx center,aligny center");
		
		JButton qcButton = new JButton("");
		qcButton.setIcon(new ImageIcon(MPMPlaning.class.getResource("/graphics/arrowDownSmall.png")));
		qcButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e)
			{
				for (JTextField iterator : qcQuantities)
					if (iterator.isEnabled())
						iterator.setText(qcTargetTextField.getText());
				
			}
		});
		panel_1.add(qcButton, "cell 9 2,alignx center,aligny center");
		
		JButton packageButton = new JButton("");
		packageButton.setIcon(new ImageIcon(MPMPlaning.class.getResource("/graphics/arrowDownSmall.png")));
		packageButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e)
			{
				for (JTextField iterator : packagingQuantities)
					if (iterator.isEnabled())
						iterator.setText(packagingTargetTextField.getText());
			}
		});
		panel_1.add(packageButton, "cell 11 2,alignx center,aligny center");
		
	
		
		// Add the elements to the panel
		
		
		
		panel_1.add(day1, "cell 3 3,alignx center,aligny center");
		panel_1.add(day2, "cell 3 4,alignx center,aligny center");
		panel_1.add(day3, "cell 3 5,alignx center,aligny center");
		panel_1.add(day4, "cell 3 6,alignx center,aligny center");
		panel_1.add(day5, "cell 3 7,alignx center,aligny center");
		panel_1.add(day6, "cell 3 8,alignx center,aligny center");
		panel_1.add(day7, "cell 3 9,alignx center,aligny center");
		panel_1.add(day8, "cell 3 10,alignx center,aligny center");
		panel_1.add(day9, "cell 3 11,alignx center,aligny center");
		panel_1.add(day10, "cell 3 12,alignx center,aligny center");
		panel_1.add(day11, "cell 3 13,alignx center,aligny center");
		panel_1.add(day12, "cell 3 14,alignx center,aligny center");
		panel_1.add(day13, "cell 3 15,alignx center,aligny center");
		panel_1.add(day14, "cell 3 16,alignx center,aligny center");
		panel_1.add(day15, "cell 3 17,alignx center,aligny center");
		panel_1.add(day16, "cell 3 18,alignx center,aligny center");
		panel_1.add(day17, "cell 3 19,alignx center,aligny center");
		panel_1.add(day18, "cell 3 20,alignx center,aligny center");
		panel_1.add(day19, "cell 3 21,alignx center,aligny center");
		panel_1.add(day20, "cell 3 22,alignx center,aligny center");
		panel_1.add(day21, "cell 3 23,alignx center,aligny center");
		panel_1.add(day22, "cell 3 24,alignx center,aligny center");
		panel_1.add(day23, "cell 3 25,alignx center,aligny center");
		panel_1.add(day24, "cell 3 26,alignx center,aligny center");
		panel_1.add(day25, "cell 3 27,alignx center,aligny center");
		panel_1.add(day26, "cell 3 28,alignx center,aligny center");
		panel_1.add(day27, "cell 3 29,alignx center,aligny center");
		panel_1.add(day28, "cell 3 30,alignx center,aligny center");
		panel_1.add(day29, "cell 3 31,alignx center,aligny center");
		panel_1.add(day30, "cell 3 32,alignx center,aligny center");
		panel_1.add(day31, "cell 3 33,alignx center,aligny center");
		
		
		
		panel_1.add(checkBox_1, "cell 1 3,alignx center");
		panel_1.add(checkBox_2, "cell 1 4,alignx center");
		panel_1.add(checkBox_3, "cell 1 5,alignx center");
		panel_1.add(checkBox_4, "cell 1 6,alignx center");
		panel_1.add(checkBox_5, "cell 1 7,alignx center");
		panel_1.add(checkBox_6, "cell 1 8,alignx center");
		panel_1.add(checkBox_7, "cell 1 9,alignx center");
		panel_1.add(checkBox_8, "cell 1 10,alignx center");
		panel_1.add(checkBox_9, "cell 1 11,alignx center");
		panel_1.add(checkBox_10, "cell 1 12,alignx center");
		panel_1.add(checkBox_11, "cell 1 13,alignx center");
		panel_1.add(checkBox_12, "cell 1 14,alignx center");
		panel_1.add(checkBox_13, "cell 1 15,alignx center");
		panel_1.add(checkBox_14, "cell 1 16,alignx center");
		panel_1.add(checkBox_15, "cell 1 17,alignx center");
		panel_1.add(checkBox_16, "cell 1 18,alignx center");
		panel_1.add(checkBox_17, "cell 1 19,alignx center");
		panel_1.add(checkBox_18, "cell 1 20,alignx center");
		panel_1.add(checkBox_19, "cell 1 21,alignx center");
		panel_1.add(checkBox_20, "cell 1 22,alignx center");
		panel_1.add(checkBox_21, "cell 1 23,alignx center");
		panel_1.add(checkBox_22, "cell 1 24,alignx center");
		panel_1.add(checkBox_23, "cell 1 25,alignx center");
		panel_1.add(checkBox_24, "cell 1 26,alignx center");
		panel_1.add(checkBox_25, "cell 1 27,alignx center");
		panel_1.add(checkBox_26, "cell 1 28,alignx center");
		panel_1.add(checkBox_27, "cell 1 29,alignx center");
		panel_1.add(checkBox_28, "cell 1 30,alignx center");
		panel_1.add(checkBox_29, "cell 1 31,alignx center");
		panel_1.add(checkBox_30, "cell 1 32,alignx center");
		panel_1.add(checkBox_31, "cell 1 33,alignx center");
		
		JLabel dayLabel = new JLabel("יום  ");
		dayLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(dayLabel, "cell 3 2,alignx center,aligny center");
		
		JLabel engraveLabel = new JLabel("ייצור");
		engraveLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(engraveLabel, "cell 5 0,alignx center,aligny center");
		
		JLabel polishingLabel = new JLabel("ליטוש");
		polishingLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(polishingLabel, "cell 7 0,alignx center,aligny center");
		
		JLabel qcLabel = new JLabel("ביקורת");
		qcLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(qcLabel, "cell 9 0,alignx center,aligny center");
		
		JLabel packagingLabel = new JLabel("אריזה");
		packagingLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(packagingLabel, "cell 11 0,alignx center,aligny center");
		
		JLabel label_1 = new JLabel("1");
		label_1.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_1, "cell 2 3,alignx center,aligny center");
		
		JLabel label_2 = new JLabel("2");
		label_2.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_2, "cell 2 4,alignx center,aligny center");
		
		JLabel label_3 = new JLabel("3");
		label_3.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_3, "cell 2 5,alignx center,aligny center");
		
		JLabel label_4 = new JLabel("4");
		label_4.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_4, "cell 2 6,alignx center,aligny center");
		
		JLabel label_5 = new JLabel("5");
		label_5.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_5, "cell 2 7,alignx center,aligny center");
		
		JLabel label_6 = new JLabel("6");
		label_6.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_6, "cell 2 8,alignx center,aligny center");
		
		JLabel label_7 = new JLabel("7");
		label_7.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_7, "cell 2 9,alignx center,aligny center");
		
		JLabel label_8 = new JLabel("8");
		label_8.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_8, "cell 2 10,alignx center,aligny center");
		
		JLabel label_9 = new JLabel("9");
		label_9.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_9, "cell 2 11,alignx center,aligny center");
		
		JLabel label_10 = new JLabel("10");
		label_10.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_10, "cell 2 12,alignx center,aligny center");
		
		JLabel label_11 = new JLabel("11");
		label_11.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_11, "cell 2 13,alignx center,aligny center");
		
		JLabel label_12 = new JLabel("12");
		label_12.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_12, "cell 2 14,alignx center,aligny center");
		
		JLabel label_13 = new JLabel("13");
		label_13.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_13, "cell 2 15,alignx center,aligny center");
		
		JLabel label_14 = new JLabel("14");
		label_14.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_14, "cell 2 16,alignx center,aligny center");
		
		JLabel label_15 = new JLabel("15");
		label_15.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_15, "cell 2 17,alignx center,aligny center");
		
		JLabel label_16 = new JLabel("16");
		label_16.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_16, "cell 2 18,alignx center,aligny center");
		
		JLabel label_17 = new JLabel("17");
		label_17.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_17, "cell 2 19,alignx center,aligny center");
		
		JLabel label_18 = new JLabel("18");
		label_18.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_18, "cell 2 20,alignx center,aligny center");
		
		JLabel label_19 = new JLabel("19");
		label_19.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_19, "cell 2 21,alignx center,aligny center");
		
		JLabel label_20 = new JLabel("20");
		label_20.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_20, "cell 2 22,alignx center,aligny center");
		
		JLabel label_21 = new JLabel("21");
		label_21.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_21, "cell 2 23,alignx center,aligny center");
		
		JLabel label_22 = new JLabel("22");
		label_22.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_22, "cell 2 24,alignx center,aligny center");
		
		JLabel label_23 = new JLabel("23");
		label_23.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_23, "cell 2 25,alignx center,aligny center");
		
		JLabel label_24 = new JLabel("24");
		label_24.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_24, "cell 2 26,alignx center,aligny center");
		
		JLabel label_25 = new JLabel("25");
		label_25.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_25, "cell 2 27,alignx center,aligny center");
		
		JLabel label_26 = new JLabel("26");
		label_26.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_26, "cell 2 28,alignx center,aligny center");
		
		JLabel label_27 = new JLabel("27");
		label_27.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_27, "cell 2 29,alignx center,aligny center");
		
		JLabel label_28 = new JLabel("28");
		label_28.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_28, "cell 2 30,alignx center");
		
		label_29 = new JLabel("29");
		label_29.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_29, "cell 2 31,alignx center,aligny center");
		
		label_30 = new JLabel("30");
		label_30.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_30, "cell 2 32,alignx center,aligny center");
		
		label_31 = new JLabel("31");
		label_31.setFont(new Font("Tahoma", Font.PLAIN, 13));
		panel_1.add(label_31, "cell 2 33,alignx center,aligny center");
		
		
		
		
		engrave1QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave1QuantityTextField.setText("0");
		panel_1.add(engrave1QuantityTextField, "cell 5 3,alignx center,aligny center");
		engrave1QuantityTextField.setColumns(3);
		
		engrave2QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave2QuantityTextField.setText("0");
		panel_1.add(engrave2QuantityTextField, "cell 5 4,alignx center,aligny center");
		engrave2QuantityTextField.setColumns(3);
		
		engrave3QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave3QuantityTextField.setText("0");
		panel_1.add(engrave3QuantityTextField, "cell 5 5,alignx center,aligny center");
		engrave3QuantityTextField.setColumns(3);
		
		engrave4QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave4QuantityTextField.setText("0");
		panel_1.add(engrave4QuantityTextField, "cell 5 6,alignx center,aligny center");
		engrave4QuantityTextField.setColumns(3);
		
		engrave5QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave5QuantityTextField.setText("0");
		panel_1.add(engrave5QuantityTextField, "cell 5 7,alignx center,aligny center");
		engrave5QuantityTextField.setColumns(3);
		
		engrave6QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave6QuantityTextField.setText("0");
		panel_1.add(engrave6QuantityTextField, "cell 5 8,alignx center,aligny center");
		engrave6QuantityTextField.setColumns(3);
		
		engrave7QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave7QuantityTextField.setText("0");
		panel_1.add(engrave7QuantityTextField, "cell 5 9,alignx center,aligny center");
		engrave7QuantityTextField.setColumns(3);
		
		engrave8QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave8QuantityTextField.setText("0");
		panel_1.add(engrave8QuantityTextField, "cell 5 10,alignx center,aligny center");
		engrave8QuantityTextField.setColumns(3);
		
		engrave9QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave9QuantityTextField.setText("0");
		panel_1.add(engrave9QuantityTextField, "cell 5 11,alignx center,aligny center");
		engrave9QuantityTextField.setColumns(3);
		
		engrave10QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave10QuantityTextField.setText("0");
		panel_1.add(engrave10QuantityTextField, "cell 5 12,alignx center,aligny center");
		engrave10QuantityTextField.setColumns(3);
		
		engrave11QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave11QuantityTextField.setText("0");
		panel_1.add(engrave11QuantityTextField, "cell 5 13,alignx center,aligny center");
		engrave11QuantityTextField.setColumns(3);
		
		engrave12QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave12QuantityTextField.setText("0");
		panel_1.add(engrave12QuantityTextField, "cell 5 14,alignx center,aligny center");
		engrave12QuantityTextField.setColumns(3);
		
		engrave13QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave13QuantityTextField.setText("0");
		panel_1.add(engrave13QuantityTextField, "cell 5 15,alignx center,aligny center");
		engrave13QuantityTextField.setColumns(3);
		
		engrave14QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave14QuantityTextField.setText("0");
		panel_1.add(engrave14QuantityTextField, "cell 5 16,alignx center,aligny center");
		engrave14QuantityTextField.setColumns(3);
		
		engrave15QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave15QuantityTextField.setText("0");
		panel_1.add(engrave15QuantityTextField, "cell 5 17,alignx center,aligny center");
		engrave15QuantityTextField.setColumns(3);
		
		engrave16QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave16QuantityTextField.setText("0");
		panel_1.add(engrave16QuantityTextField, "cell 5 18,alignx center,aligny center");
		engrave16QuantityTextField.setColumns(3);
		
		engrave17QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave17QuantityTextField.setText("0");
		panel_1.add(engrave17QuantityTextField, "cell 5 19,alignx center,aligny center");
		engrave17QuantityTextField.setColumns(3);
		
		engrave18QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave18QuantityTextField.setText("0");
		panel_1.add(engrave18QuantityTextField, "cell 5 20,alignx center,aligny center");
		engrave18QuantityTextField.setColumns(3);
		
		engrave19QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave19QuantityTextField.setText("0");
		panel_1.add(engrave19QuantityTextField, "cell 5 21,alignx center,aligny center");
		engrave19QuantityTextField.setColumns(3);
		
		engrave20QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave20QuantityTextField.setText("0");
		panel_1.add(engrave20QuantityTextField, "cell 5 22,alignx center,aligny center");
		engrave20QuantityTextField.setColumns(3);
		
		engrave21QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave21QuantityTextField.setText("0");
		panel_1.add(engrave21QuantityTextField, "cell 5 23,alignx center,aligny center");
		engrave21QuantityTextField.setColumns(3);
		
		engrave22QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave22QuantityTextField.setText("0");
		panel_1.add(engrave22QuantityTextField, "cell 5 24,alignx center,aligny center");
		engrave22QuantityTextField.setColumns(3);
		
		engrave23QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave23QuantityTextField.setText("0");
		panel_1.add(engrave23QuantityTextField, "cell 5 25,alignx center,aligny center");
		engrave23QuantityTextField.setColumns(3);
		
		engrave24QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave24QuantityTextField.setText("0");
		panel_1.add(engrave24QuantityTextField, "cell 5 26,alignx center,aligny center");
		engrave24QuantityTextField.setColumns(3);
		
		engrave25QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave25QuantityTextField.setText("0");
		panel_1.add(engrave25QuantityTextField, "cell 5 27,alignx center,aligny center");
		engrave25QuantityTextField.setColumns(3);
		
		engrave26QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave26QuantityTextField.setText("0");
		panel_1.add(engrave26QuantityTextField, "cell 5 28,alignx center,aligny center");
		engrave26QuantityTextField.setColumns(3);
		
		engrave27QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave27QuantityTextField.setText("0");
		panel_1.add(engrave27QuantityTextField, "cell 5 29,alignx center,aligny center");
		engrave27QuantityTextField.setColumns(3);
		
		engrave28QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave28QuantityTextField.setText("0");
		panel_1.add(engrave28QuantityTextField, "cell 5 30,alignx center,aligny center");
		engrave28QuantityTextField.setColumns(3);
		
		engrave29QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave29QuantityTextField.setText("0");
		panel_1.add(engrave29QuantityTextField, "cell 5 31,alignx center,aligny center");
		engrave29QuantityTextField.setColumns(3);
		
		engrave30QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave30QuantityTextField.setText("0");
		panel_1.add(engrave30QuantityTextField, "cell 5 32,alignx center,aligny center");
		engrave30QuantityTextField.setColumns(3);
		
		engrave31QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		engrave31QuantityTextField.setText("0");
		panel_1.add(engrave31QuantityTextField, "cell 5 33,alignx center,aligny center");
		engrave31QuantityTextField.setColumns(3);
		
		polish1QuantityTextField.setText("0");
		polish1QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish1QuantityTextField, "cell 7 3,alignx center,aligny center");
		polish1QuantityTextField.setColumns(3);
		
		polish2QuantityTextField.setText("0");
		polish2QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish2QuantityTextField, "cell 7 4,alignx center,aligny center");
		polish2QuantityTextField.setColumns(3);

		polish3QuantityTextField.setText("0");
		polish3QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish3QuantityTextField, "cell 7 5,alignx center,aligny center");
		polish3QuantityTextField.setColumns(3);

		polish4QuantityTextField.setText("0");
		polish4QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish4QuantityTextField, "cell 7 6,alignx center,aligny center");
		polish4QuantityTextField.setColumns(3);

		polish5QuantityTextField.setText("0");
		polish5QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish5QuantityTextField, "cell 7 7,alignx center,aligny center");
		polish5QuantityTextField.setColumns(3);

		polish6QuantityTextField.setText("0");
		polish6QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish6QuantityTextField, "cell 7 8,alignx center,aligny center");
		polish6QuantityTextField.setColumns(3);

		polish7QuantityTextField.setText("0");
		polish7QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish7QuantityTextField, "cell 7 9,alignx center,aligny center");
		polish7QuantityTextField.setColumns(3);

		polish8QuantityTextField.setText("0");
		polish8QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish8QuantityTextField, "cell 7 10,alignx center,aligny center");
		polish8QuantityTextField.setColumns(3);

		polish9QuantityTextField.setText("0");
		polish9QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish9QuantityTextField, "cell 7 11,alignx center,aligny center");
		polish9QuantityTextField.setColumns(3);

		polish10QuantityTextField.setText("0");
		polish10QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish10QuantityTextField, "cell 7 12,alignx center,aligny center");
		polish10QuantityTextField.setColumns(3);

		polish11QuantityTextField.setText("0");
		polish11QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish11QuantityTextField, "cell 7 13,alignx center,aligny center");
		polish11QuantityTextField.setColumns(3);

		polish12QuantityTextField.setText("0");
		polish12QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish12QuantityTextField, "cell 7 14,alignx center,aligny center");
		polish12QuantityTextField.setColumns(3);

		polish13QuantityTextField.setText("0");
		polish13QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish13QuantityTextField, "cell 7 15,alignx center,aligny center");
		polish13QuantityTextField.setColumns(3);

		polish14QuantityTextField.setText("0");
		polish14QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish14QuantityTextField, "cell 7 16,alignx center,aligny center");
		polish14QuantityTextField.setColumns(3);

		polish15QuantityTextField.setText("0");
		polish15QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish15QuantityTextField, "cell 7 17,alignx center,aligny center");
		polish15QuantityTextField.setColumns(3);

		polish16QuantityTextField.setText("0");
		polish16QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish16QuantityTextField, "cell 7 18,alignx center,aligny center");
		polish16QuantityTextField.setColumns(3);

		polish17QuantityTextField.setText("0");
		polish17QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish17QuantityTextField, "cell 7 19,alignx center,aligny center");
		polish17QuantityTextField.setColumns(3);

		polish18QuantityTextField.setText("0");
		polish18QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish18QuantityTextField, "cell 7 20,alignx center,aligny center");
		polish18QuantityTextField.setColumns(3);

		polish19QuantityTextField.setText("0");
		polish19QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish19QuantityTextField, "cell 7 21,alignx center,aligny center");
		polish19QuantityTextField.setColumns(3);

		polish20QuantityTextField.setText("0");
		polish20QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish20QuantityTextField, "cell 7 22,alignx center,aligny center");
		polish20QuantityTextField.setColumns(3);

		polish21QuantityTextField.setText("0");
		polish21QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish21QuantityTextField, "cell 7 23,alignx center,aligny center");
		polish21QuantityTextField.setColumns(3);

		polish22QuantityTextField.setText("0");
		polish22QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish22QuantityTextField, "cell 7 24,alignx center,aligny center");
		polish22QuantityTextField.setColumns(3);

		polish23QuantityTextField.setText("0");
		polish23QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish23QuantityTextField, "cell 7 25,alignx center,aligny center");
		polish23QuantityTextField.setColumns(3);

		polish24QuantityTextField.setText("0");
		polish24QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish24QuantityTextField, "cell 7 26,alignx center,aligny center");
		polish24QuantityTextField.setColumns(3);

		polish25QuantityTextField.setText("0");
		polish25QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish25QuantityTextField, "cell 7 27,alignx center,aligny center");
		polish25QuantityTextField.setColumns(3);

		polish26QuantityTextField.setText("0");
		polish26QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish26QuantityTextField, "cell 7 28,alignx center,aligny center");
		polish26QuantityTextField.setColumns(3);

		polish27QuantityTextField.setText("0");
		polish27QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish27QuantityTextField, "cell 7 29,alignx center,aligny center");
		polish27QuantityTextField.setColumns(3);

		polish28QuantityTextField.setText("0");
		polish28QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish28QuantityTextField, "cell 7 30,alignx center,aligny center");
		polish28QuantityTextField.setColumns(3);

		polish29QuantityTextField.setText("0");
		polish29QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish29QuantityTextField, "cell 7 31,alignx center,aligny center");
		polish29QuantityTextField.setColumns(3);

		polish30QuantityTextField.setText("0");
		polish30QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish30QuantityTextField, "cell 7 32,alignx center,aligny center");
		polish30QuantityTextField.setColumns(3);

		polish31QuantityTextField.setText("0");
		polish31QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(polish31QuantityTextField, "cell 7 33,alignx center,aligny center");
		polish31QuantityTextField.setColumns(3);

		qc1QuantityTextField.setText("0");
		qc1QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc1QuantityTextField, "cell 9 3,alignx center,aligny center");
		qc1QuantityTextField.setColumns(3);
		
		qc2QuantityTextField.setText("0");
		qc2QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc2QuantityTextField, "cell 9 4,alignx center,aligny center");
		qc2QuantityTextField.setColumns(3);

		qc3QuantityTextField.setText("0");
		qc3QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc3QuantityTextField, "cell 9 5,alignx center,aligny center");
		qc3QuantityTextField.setColumns(3);

		qc4QuantityTextField.setText("0");
		qc4QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc4QuantityTextField, "cell 9 6,alignx center,aligny center");
		qc4QuantityTextField.setColumns(3);

		qc5QuantityTextField.setText("0");
		qc5QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc5QuantityTextField, "cell 9 7,alignx center,aligny center");
		qc5QuantityTextField.setColumns(3);

		qc6QuantityTextField.setText("0");
		qc6QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc6QuantityTextField, "cell 9 8,alignx center,aligny center");
		qc6QuantityTextField.setColumns(3);

		qc7QuantityTextField.setText("0");
		qc7QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc7QuantityTextField, "cell 9 9,alignx center,aligny center");
		qc7QuantityTextField.setColumns(3);

		qc8QuantityTextField.setText("0");
		qc8QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc8QuantityTextField, "cell 9 10,alignx center,aligny center");
		qc8QuantityTextField.setColumns(3);

		qc9QuantityTextField.setText("0");
		qc9QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc9QuantityTextField, "cell 9 11,alignx center,aligny center");
		qc9QuantityTextField.setColumns(3);

		qc10QuantityTextField.setText("0");
		qc10QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc10QuantityTextField, "cell 9 12,alignx center,aligny center");
		qc10QuantityTextField.setColumns(3);

		qc11QuantityTextField.setText("0");
		qc11QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc11QuantityTextField, "cell 9 13,alignx center,aligny center");
		qc11QuantityTextField.setColumns(3);

		qc12QuantityTextField.setText("0");
		qc12QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc12QuantityTextField, "cell 9 14,alignx center,aligny center");
		qc12QuantityTextField.setColumns(3);

		qc13QuantityTextField.setText("0");
		qc13QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc13QuantityTextField, "cell 9 15,alignx center,aligny center");
		qc13QuantityTextField.setColumns(3);

		qc14QuantityTextField.setText("0");
		qc14QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc14QuantityTextField, "cell 9 16,alignx center,aligny center");
		qc14QuantityTextField.setColumns(3);

		qc15QuantityTextField.setText("0");
		qc15QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc15QuantityTextField, "cell 9 17,alignx center,aligny center");
		qc15QuantityTextField.setColumns(3);

		qc16QuantityTextField.setText("0");
		qc16QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc16QuantityTextField, "cell 9 18,alignx center,aligny center");
		qc16QuantityTextField.setColumns(3);

		qc17QuantityTextField.setText("0");
		qc17QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc17QuantityTextField, "cell 9 19,alignx center,aligny center");
		qc17QuantityTextField.setColumns(3);

		qc18QuantityTextField.setText("0");
		qc18QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc18QuantityTextField, "cell 9 20,alignx center,aligny center");
		qc18QuantityTextField.setColumns(3);

		qc19QuantityTextField.setText("0");
		qc19QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc19QuantityTextField, "cell 9 21,alignx center,aligny center");
		qc19QuantityTextField.setColumns(3);

		qc20QuantityTextField.setText("0");
		qc20QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc20QuantityTextField, "cell 9 22,alignx center,aligny center");
		qc20QuantityTextField.setColumns(3);

		qc21QuantityTextField.setText("0");
		qc21QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc21QuantityTextField, "cell 9 23,alignx center,aligny center");
		qc21QuantityTextField.setColumns(3);

		qc22QuantityTextField.setText("0");
		qc22QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc22QuantityTextField, "cell 9 24,alignx center,aligny center");
		qc22QuantityTextField.setColumns(3);

		qc23QuantityTextField.setText("0");
		qc23QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc23QuantityTextField, "cell 9 25,alignx center,aligny center");
		qc23QuantityTextField.setColumns(3);

		qc24QuantityTextField.setText("0");
		qc24QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc24QuantityTextField, "cell 9 26,alignx center,aligny center");
		qc24QuantityTextField.setColumns(3);

		qc25QuantityTextField.setText("0");
		qc25QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc25QuantityTextField, "cell 9 27,alignx center,aligny center");
		qc25QuantityTextField.setColumns(3);

		qc26QuantityTextField.setText("0");
		qc26QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc26QuantityTextField, "cell 9 28,alignx center,aligny center");
		qc26QuantityTextField.setColumns(3);

		qc27QuantityTextField.setText("0");
		qc27QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc27QuantityTextField, "cell 9 29,alignx center,aligny center");
		qc27QuantityTextField.setColumns(3);

		qc28QuantityTextField.setText("0");
		qc28QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc28QuantityTextField, "cell 9 30,alignx center,aligny center");
		qc28QuantityTextField.setColumns(3);

		qc29QuantityTextField.setText("0");
		qc29QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc29QuantityTextField, "cell 9 31,alignx center,aligny center");
		qc29QuantityTextField.setColumns(3);

		qc30QuantityTextField.setText("0");
		qc30QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc30QuantityTextField, "cell 9 32,alignx center,aligny center");
		qc30QuantityTextField.setColumns(3);

		qc31QuantityTextField.setText("0");
		qc31QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(qc31QuantityTextField, "cell 9 33,alignx center,aligny center");
		qc31QuantityTextField.setColumns(3);

		packaging1QuantityTextField.setText("0");
		packaging1QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging1QuantityTextField, "cell 11 3,alignx center,aligny center");
		packaging1QuantityTextField.setColumns(3);
		
		packaging2QuantityTextField.setText("0");
		packaging2QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging2QuantityTextField, "cell 11 4,alignx center,aligny center");
		packaging2QuantityTextField.setColumns(3);

		packaging3QuantityTextField.setText("0");
		packaging3QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging3QuantityTextField, "cell 11 5,alignx center,aligny center");
		packaging3QuantityTextField.setColumns(3);

		packaging4QuantityTextField.setText("0");
		packaging4QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging4QuantityTextField, "cell 11 6,alignx center,aligny center");
		packaging4QuantityTextField.setColumns(3);

		packaging5QuantityTextField.setText("0");
		packaging5QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging5QuantityTextField, "cell 11 7,alignx center,aligny center");
		packaging5QuantityTextField.setColumns(3);

		packaging6QuantityTextField.setText("0");
		packaging6QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging6QuantityTextField, "cell 11 8,alignx center,aligny center");
		packaging6QuantityTextField.setColumns(3);

		packaging7QuantityTextField.setText("0");
		packaging7QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging7QuantityTextField, "cell 11 9,alignx center,aligny center");
		packaging7QuantityTextField.setColumns(3);

		packaging8QuantityTextField.setText("0");
		packaging8QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging8QuantityTextField, "cell 11 10,alignx center,aligny center");
		packaging8QuantityTextField.setColumns(3);

		packaging9QuantityTextField.setText("0");
		packaging9QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging9QuantityTextField, "cell 11 11,alignx center,aligny center");
		packaging9QuantityTextField.setColumns(3);

		packaging10QuantityTextField.setText("0");
		packaging10QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging10QuantityTextField, "cell 11 12,alignx center,aligny center");
		packaging10QuantityTextField.setColumns(3);

		packaging11QuantityTextField.setText("0");
		packaging11QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging11QuantityTextField, "cell 11 13,alignx center,aligny center");
		packaging11QuantityTextField.setColumns(3);

		packaging12QuantityTextField.setText("0");
		packaging12QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging12QuantityTextField, "cell 11 14,alignx center,aligny center");
		packaging12QuantityTextField.setColumns(3);

		packaging13QuantityTextField.setText("0");
		packaging13QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging13QuantityTextField, "cell 11 15,alignx center,aligny center");
		packaging13QuantityTextField.setColumns(3);

		packaging14QuantityTextField.setText("0");
		packaging14QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging14QuantityTextField, "cell 11 16,alignx center,aligny center");
		packaging14QuantityTextField.setColumns(3);

		packaging15QuantityTextField.setText("0");
		packaging15QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging15QuantityTextField, "cell 11 17,alignx center,aligny center");
		packaging15QuantityTextField.setColumns(3);

		packaging16QuantityTextField.setText("0");
		packaging16QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging16QuantityTextField, "cell 11 18,alignx center,aligny center");
		packaging16QuantityTextField.setColumns(3);

		packaging17QuantityTextField.setText("0");
		packaging17QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging17QuantityTextField, "cell 11 19,alignx center,aligny center");
		packaging17QuantityTextField.setColumns(3);

		packaging18QuantityTextField.setText("0");
		packaging18QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging18QuantityTextField, "cell 11 20,alignx center,aligny center");
		packaging18QuantityTextField.setColumns(3);

		packaging19QuantityTextField.setText("0");
		packaging19QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging19QuantityTextField, "cell 11 21,alignx center,aligny center");
		packaging19QuantityTextField.setColumns(3);

		packaging20QuantityTextField.setText("0");
		packaging20QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging20QuantityTextField, "cell 11 22,alignx center,aligny center");
		packaging20QuantityTextField.setColumns(3);

		packaging21QuantityTextField.setText("0");
		packaging21QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging21QuantityTextField, "cell 11 23,alignx center,aligny center");
		packaging21QuantityTextField.setColumns(3);

		packaging22QuantityTextField.setText("0");
		packaging22QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging22QuantityTextField, "cell 11 24,alignx center,aligny center");
		packaging22QuantityTextField.setColumns(3);

		packaging23QuantityTextField.setText("0");
		packaging23QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging23QuantityTextField, "cell 11 25,alignx center,aligny center");
		packaging23QuantityTextField.setColumns(3);

		packaging24QuantityTextField.setText("0");
		packaging24QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging24QuantityTextField, "cell 11 26,alignx center,aligny center");
		packaging24QuantityTextField.setColumns(3);

		packaging25QuantityTextField.setText("0");
		packaging25QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging25QuantityTextField, "cell 11 27,alignx center,aligny center");
		packaging25QuantityTextField.setColumns(3);

		packaging26QuantityTextField.setText("0");
		packaging26QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging26QuantityTextField, "cell 11 28,alignx center,aligny center");
		packaging26QuantityTextField.setColumns(3);

		packaging27QuantityTextField.setText("0");
		packaging27QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging27QuantityTextField, "cell 11 29,alignx center,aligny center");
		packaging27QuantityTextField.setColumns(3);

		packaging28QuantityTextField.setText("0");
		packaging28QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging28QuantityTextField, "cell 11 30,alignx center,aligny center");
		packaging28QuantityTextField.setColumns(3);

		packaging29QuantityTextField.setText("0");
		packaging29QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging29QuantityTextField, "cell 11 31,alignx center,aligny center");
		packaging29QuantityTextField.setColumns(3);

		packaging30QuantityTextField.setText("0");
		packaging30QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging30QuantityTextField, "cell 11 32,alignx center,aligny center");
		packaging30QuantityTextField.setColumns(3);

		packaging31QuantityTextField.setText("0");
		packaging31QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(packaging31QuantityTextField, "cell 11 33,alignx center,aligny center");
		packaging31QuantityTextField.setColumns(3);
		
		exitButton = new javax.swing.JButton();
		exitButton.setFont(new Font("Tahoma", Font.PLAIN, 13));
		exitButton.setIcon(new ImageIcon(MPMPlaning.class.getResource("/graphics/exit.png")));
        exitButton.setText("יציאה מהמערכת");
        exitButton.addMouseListener(new MouseAdapter()
        {
        	@Override
        	public void mouseClicked(MouseEvent arg0) 
        	{
        		
        		Object[] options = {"כן","לא"};
        		int n = JOptionPane.showOptionDialog(myframe, "האם ברצונך לצאת מהמערכת?","אישור יציאה", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,"");
        		
        		if (n==0)
        		{
            		
        			if (MPMFrame.mpmClient!= null)
                    {
                      try
                      {
                    	  MPMFrame.mpmClient.close();
                      }
                      catch (Exception ignore)
                      {}
                     }
            		
            		System.exit(0);
            	}
            		
            		
        		//Close connections to the server
        		
        	}
        });
		
        panel.add(exitButton, "flowx,cell 1 2,alignx center,aligny center");
        
        createPlan = new JButton("צור תכנון");
        createPlan.setFont(new Font("Tahoma", Font.PLAIN, 13));
        createPlan.setIcon(new ImageIcon(MPMPlaning.class.getResource("/graphics/apply.png")));
        createPlan.addMouseListener(new MouseAdapter() {
        	@Override
        	public void mouseClicked(MouseEvent e)
        	{
        		if (everythingIsValid())
        			createSchedule();				
        	}
        });
        
        JLabel lblNewLabel = new JLabel("               ");
        panel.add(lblNewLabel, "cell 1 2");
        panel.add(createPlan, "cell 1 2,alignx center,aligny center");
		
		
		
		
		
		


		
		
		/*
		polish1QuantityTextField.setText("0");
		polish1QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		polish1QuantityTextField.setColumns(3);
		panel_1.add(polish1QuantityTextField, "cell 8 4,alignx center,aligny center");
		

		qc1QuantityTextField.setText("0");
		qc1QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		qc1QuantityTextField.setColumns(3);
		panel_1.add(qc1QuantityTextField, "cell 11 4,alignx center,aligny center");
		
		
		packaging1QuantityTextField.setText("0");
		packaging1QuantityTextField.setHorizontalAlignment(SwingConstants.CENTER);
		packaging1QuantityTextField.setColumns(3);
		panel_1.add(packaging1QuantityTextField, "cell 14 4,alignx center,aligny center");
		
		*/
		
		
		
		
		
		
		initialize();
	}

	
	
	
// Old Version
	/*
	protected void createSchedule()
	{
		ArrayList<Object> schedule = new ArrayList<Object>();
		schedule.add("createNewSchedule");

		ArrayList<Object> engraveSchedule = new ArrayList<Object>();
		ArrayList<Object> polishSchedule = new ArrayList<Object>();
		ArrayList<Object> qcSchedule = new ArrayList<Object>();
		ArrayList<Object>packagingSchedule = new ArrayList<Object>();
		
		String scheduleID = (monthComboBox.getSelectedIndex()+1) + yearComboBox.getSelectedItem().toString();
		
		engraveSchedule.add(scheduleID);
		engraveSchedule.add("engraving");
		
		for (JTextField iterator : engraveQuantities)
			engraveSchedule.add(iterator.getText());

		polishSchedule.add(scheduleID);
		polishSchedule.add("polishing");
		
		for (JTextField iterator : polishQuantities)
			polishSchedule.add(iterator.getText());
		
		qcSchedule.add(scheduleID);
		qcSchedule.add("qualityControl");
		
		for (JTextField iterator : qcQuantities)
			qcSchedule.add(iterator.getText());
		
		packagingSchedule.add(scheduleID);
		packagingSchedule.add("packaging");
		
		for (JTextField iterator : packagingQuantities)
			packagingSchedule.add(iterator.getText());
		
		schedule.add(engraveSchedule);
		schedule.add(polishSchedule);
		schedule.add(qcSchedule);
		schedule.add(packagingSchedule);
		
		// send to DB
		
		
		try
		{
			ArrayList<Object> response = new ArrayList<Object>();
			response = myframe.mpmClient.call(schedule);
			
			if (response.get(0).toString().equals("valid"))
			{
				//success
				JOptionPane.showMessageDialog(myframe,
        			    "תכנון הוזן למערכת בהצלחה.","אישור",JOptionPane.INFORMATION_MESSAGE);
			}
			else
			if (response.get(0).toString().equals("SQL Error"))
			{
				// Failed in SQL Server
				JOptionPane.showMessageDialog(myframe,
        			    "תקלה בבסיס הנתונים.","שגיאה",JOptionPane.ERROR_MESSAGE);
			}
		}
		catch (Exception e)
		{
			// Connection Error
			JOptionPane.showMessageDialog(myframe,
    			    "תקלה בתקשורת הנתונים לשרת.","שגיאה",JOptionPane.ERROR_MESSAGE);
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}
		

		
		
		
		// TODO Auto-generated method stub
		
	}

*/

	
	/**
	 * Creates a schedule 
	 */
	protected void createSchedule()
	{
		createPlan.setEnabled(false);
		
		ArrayList<Object> schedule = new ArrayList<Object>();
		schedule.add("createNewSchedule"); // index 0
		
		// create scheduleID
		
		int monthInt =(monthComboBox.getSelectedIndex()+1);
		String month = new String();
		
		if (monthInt <10)
		{
			month = "0" + String.valueOf(monthInt);
		}
		else
		{
			month = String.valueOf(monthInt);
		}
			
		String scheduleID = yearComboBox.getSelectedItem().toString() + month;
		schedule.add(scheduleID); // index 1
		
		ArrayList<Object> engraveSchedule = new ArrayList<Object>();
		ArrayList<Object> polishSchedule = new ArrayList<Object>();
		ArrayList<Object> qcSchedule = new ArrayList<Object>();
		ArrayList<Object>packagingSchedule = new ArrayList<Object>();

		
	
		
		for (JTextField iterator : engraveQuantities)
			engraveSchedule.add(iterator.getText());
	
		
		for (JTextField iterator : polishQuantities)
			polishSchedule.add(iterator.getText());
		
	
		for (JTextField iterator : qcQuantities)
			qcSchedule.add(iterator.getText());

		
		for (JTextField iterator : packagingQuantities)
			packagingSchedule.add(iterator.getText());
		
		schedule.add(engraveSchedule); // index 2
		schedule.add(polishSchedule);	// index 3
		schedule.add(qcSchedule);	// index 4
		schedule.add(packagingSchedule);	// index 5
		
		// send to DB
		
		
		try
		{
			ArrayList<Object> response = new ArrayList<Object>();
			response = myframe.mpmClient.call(schedule);
			
			if (response.get(0).toString().equals("valid"))
			{
				//success
				JOptionPane.showMessageDialog(myframe,
        			    "תכנון הוזן למערכת בהצלחה.","אישור",JOptionPane.INFORMATION_MESSAGE);
			}
			else
			if (response.get(0).toString().equals("SQL Error"))
			{
				// Failed in SQL Server
				JOptionPane.showMessageDialog(myframe,
        			    "תקלה בבסיס הנתונים.","שגיאה",JOptionPane.ERROR_MESSAGE);
			}
		}
		catch (Exception e)
		{
			// Connection Error
			JOptionPane.showMessageDialog(myframe,
    			    "תקלה בתקשורת הנתונים לשרת.","שגיאה",JOptionPane.ERROR_MESSAGE);
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}
		
		
		createPlan.setEnabled(true);
		
	}
	
	

/**
 * Test for validity of the input
 */
	protected boolean everythingIsValid() 
	{
		boolean flag = true;
		
		for (JTextField iterator : engraveQuantities)
		{
			flag = Services.isNumeric(iterator.getText());
			if (!flag)
				return false;
		}
		
		for (JTextField iterator : polishQuantities)
		{
			flag = Services.isNumeric(iterator.getText());
			if (!flag)
				return false;
		}
		
		for (JTextField iterator : qcQuantities)
		{
			flag = Services.isNumeric(iterator.getText());
			if (!flag)
				return false;
		}
		
		for (JTextField iterator : packagingQuantities)
		{
			flag = Services.isNumeric(iterator.getText());
			if (!flag)
				return false;
		}
		
		return true;
	}



/**
 * Initialize GUI elements
 */

	private void initialize()
	{
		// handle independent elements (Calendar)
		
		Calendar today = Calendar.getInstance();
		
		// initialize yearComboBox
		int year = today.get(Calendar.YEAR);
		yearComboBox.addItem(year-1);
		yearComboBox.addItem(year);
		yearComboBox.addItem(year+1);
		yearComboBox.setSelectedIndex(1);
		
		// get the first day of the month
		monthComboBox.setSelectedIndex(today.get(Calendar.MONTH));
		int month = today.getMaximum(Calendar.MONTH);
		
		initializeFields(year,month, true);

		 
		
		// handle dependent elements (Schedule)
	}
	
	/**
	 * Initializes GUI Data in the GUI labels
	 */
	public void initializeFields(int year, int month, boolean firstRun)
	{
		Calendar calendar = new GregorianCalendar();
		calendar.set(Calendar.YEAR,year);
		calendar.set(Calendar.MONTH,month);
		calendar.set(Calendar.DAY_OF_MONTH,1);
		
		int dayOfTheWeek = calendar.get(Calendar.DAY_OF_WEEK);
		int numberOfDaysInTheMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
		
		String[] daysOfTheMonth = {"empty","א","ב","ג","ד","ה","ו","ש","א","ב","ג","ד","ה","ו","ש","א","ב","ג","ד","ה","ו","ש","א","ב","ג","ד","ה","ו","ש","א","ב","ג","ד","ה","ו","ש","א","ב"};

		//	initialize dynamically
 	
		int index = 0;
		
		for ( JLabel dayLabelIterator : dayLabels )
		 {
			String day = daysOfTheMonth[dayOfTheWeek];
			dayLabelIterator.setText(day); // set the day text
			if ( day.equals("ו") || day.equals("ש") )
			{
				// this is not a work day
				engraveQuantities[index].setText("0");
				polishQuantities[index].setText("0");
				qcQuantities[index].setText("0");
				packagingQuantities[index].setText("0");
				setRowElements(index,false);
				
			}
			else
			{
				setRowElements(index,true);
			}
			
			index++;
		 		 
			
			dayOfTheWeek++;	
		 }
		
		
		// check for the 29th, 30th and 31st
		
		if (29<=numberOfDaysInTheMonth && workdayChoice[28].isEnabled() )
		{
			setRowElements(28, true);
			showRowElements(28, true);
			label_29.setVisible(true);
		}
		else
		{
			setRowElements(28,false);
			showRowElements(28,false);
			label_29.setVisible(false);
			
		}

		if (30<=numberOfDaysInTheMonth && workdayChoice[29].isEnabled() )
		{
			setRowElements(29, true);
			showRowElements(29,true);
			label_30.setVisible(true);
		}
		else
		{
			setRowElements(29,false);
			showRowElements(29,false);
			label_30.setVisible(false);
		}

		if (30<=numberOfDaysInTheMonth && workdayChoice[30].isEnabled() )
		{
			setRowElements(30, true);
			showRowElements(30,true);
			label_31.setVisible(true);
		}
		else
		{
			setRowElements(30,false);
			showRowElements(30,false);
			label_31.setVisible(false);
		}

		
		setValuesToFields(firstRun);
		
	}


	/**
	 * Sets data to the GUI Textfields
	 */
	private void setValuesToFields(boolean firstRun)
	{
		

		/** see if there's a schedule in the DB
		*if so - set values to the fields
		* else - set zeroes
		* 
		*/
		
		
		ArrayList<Object> message = new ArrayList<Object>();
		ArrayList<Object> response = new ArrayList<Object>();
		
		
		
		message.add("getSchedule");
		int monthInt =(monthComboBox.getSelectedIndex()+1);
		String month = new String();
		
		if (monthInt <10)
		{
			month = "0" + String.valueOf(monthInt);
		}
		else
		{
			month = String.valueOf(monthInt);
		}
			
		String scheduleID = yearComboBox.getSelectedItem().toString() + month;
		message.add(scheduleID);
		
		try 
		{
			response = myframe.mpmClient.call(message);
					
			if (response.get(0).toString().equalsIgnoreCase("valid"))
			{
	
				// get the arraylists
				ArrayList<Object> engrave = (ArrayList<Object>)response.get(1);
				ArrayList<Object> polish = (ArrayList<Object>)response.get(2);
				ArrayList<Object> qc = (ArrayList<Object>)response.get(3);
				ArrayList<Object> packaging = (ArrayList<Object>)response.get(4);
				
				
				// set values. 0 means disable row
				int arrayListIndex = 1;
				int elementIndex=0;
				
				if (engrave.get(0).toString().equalsIgnoreCase("valid"))
				{
					for (JTextField iterator : engraveQuantities)
					{
						String value = (String)engrave.get(arrayListIndex);
						iterator.setText(value);
						workdaysFlagArray1[elementIndex] = Integer.parseInt(value);
						elementIndex++;
						arrayListIndex++;
						
					}
				}
				else
				{
					//no schedule, set zeroes
					
					
				}
				
				
				arrayListIndex = 1;
				elementIndex=0;
				
				if (polish.get(0).toString().equalsIgnoreCase("valid"))
				{
					for (JTextField iterator : polishQuantities)
					{
						String value = (String)polish.get(arrayListIndex);
						iterator.setText(value);
						workdaysFlagArray2[elementIndex] = Integer.parseInt(value);
						elementIndex++;
						arrayListIndex++;
					}
				}
				else
				{
					//no schedule, set zeroes
					
				}
				
				
				
				arrayListIndex = 1;
				elementIndex=0;
				
				if (qc.get(0).toString().equalsIgnoreCase("valid"))
				{
					for (JTextField iterator : qcQuantities)
					{
						String value = (String)qc.get(arrayListIndex);
						iterator.setText(value);
						workdaysFlagArray3[elementIndex] = Integer.parseInt(value);
						elementIndex++;
						arrayListIndex++;
					}
				}
				else
				{
					//no schedule, set zeroes
				
					
				}
				
				
				
				
				arrayListIndex = 1;
				elementIndex=0;
				
				if (packaging.get(0).toString().equalsIgnoreCase("valid"))
				{
					for (JTextField iterator : packagingQuantities)
					{
						String value = (String)packaging.get(arrayListIndex);
						iterator.setText(value);
						workdaysFlagArray4[elementIndex] = Integer.parseInt(value);
						elementIndex++;
						arrayListIndex++;
					}
				}
				else
				{
					//no schedule, set zeroes
	
					
				}
				
				// check if all 4 elements are 0, if so - disable row
				// else - enable row
				
				for (int row=0; row<31;row++)
				{
					if ( (workdaysFlagArray1[row]==0)  && (workdaysFlagArray2[row]==0) && (workdaysFlagArray3[row]==0) && (workdaysFlagArray4[row]==0) )
						setRowElements(row, false);					
					else
						setRowElements(row, true);
				}


				
				
			}
			else
			if (response.get(0).toString().equalsIgnoreCase("SQL Error"))
			{
				// sql error error
				JOptionPane.showMessageDialog(myframe,
	        		    "תקלה בבסיס הנתונים.","שגיאה",JOptionPane.ERROR_MESSAGE);
			}
			else
			{
				// no schedule was found dialog
				if (!firstRun)
				{
				JOptionPane.showMessageDialog(myframe,
        			    "לא נמצא תכנון במערכת עבור התאריך שנבחר.","לא נמצא תכנון",JOptionPane.INFORMATION_MESSAGE);
				}
				//TODO set everything to 0
				
				
				for (JTextField iterator : engraveQuantities)
					iterator.setText("0");
				for (JTextField iterator : polishQuantities)
					iterator.setText("0");
				for (JTextField iterator : qcQuantities)
					iterator.setText("0");
				for (JTextField iterator : packagingQuantities)
					iterator.setText("0");
				
			}
			
		} 
		catch (Exception e)
		{
			// connection error
			JOptionPane.showMessageDialog(myframe,
    			    "תקלה בתקשורת הנתונים לשרת.","שגיאה",JOptionPane.ERROR_MESSAGE);
			
			//e.printStackTrace();
		}	
		
		
		

		
	}
	
	/**
	 * Handles GUI rows visibility during initialization
	 */
	private void checkBoxClicked(ItemEvent arg0, int index)
	{
			if (arg0.getStateChange() == ItemEvent.SELECTED)
				setRowElements(index, true);
			else
			{
				engraveQuantities[index].setText("0");
				polishQuantities[index].setText("0");
				qcQuantities[index].setText("0");
				packagingQuantities[index].setText("0");
				setRowElements(index, false);
				
			}
	}
	
	/**
	 * Sets data to selected row
	 */
	private void setRowElements(int index, boolean bool)
	{
		workdayChoice[index].setSelected(bool);	
		engraveQuantities[index].setEnabled(bool);
		polishQuantities[index].setEnabled(bool);
		qcQuantities[index].setEnabled(bool);
		packagingQuantities[index].setEnabled(bool);		
	}
	
	/**
	 * Handle GUI row visibility according to user input 
	 */
	private void showRowElements(int index, boolean bool)
	{
		workdayChoice[index].setVisible(bool);
		engraveQuantities[index].setVisible(bool);
		polishQuantities[index].setVisible(bool);
		qcQuantities[index].setVisible(bool);
		packagingQuantities[index].setVisible(bool);	
		dayLabels[index].setVisible(bool);
	}
	
	@Override
	public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    Color color1 = getBackground();
    Color color2 = color1.darker();
    int w = getWidth();
    int h = getHeight(); 
    GradientPaint gp = new GradientPaint(
            0, 0, color1,
            0, h, color2);

    g2d.setPaint(gp);
    g2d.fillRect(0, 0, w, h);
    }
}
